package com.ry.bhwktapp.home.ui

/**
 * kotlin 语言实现加密解密（使用字符串的replace方法）
 */
fun main() {
    val originStr ="QWERTYUIOPASDFGHJKLZXCVBNM"
    //模拟加密
    val paw = originStr.replace(Regex("[QWERT]")) {
        when (it.value) {
            "Q" -> "1"
            "W" -> "2"
            "E" -> "3"
            "R" -> "4"
            "T" -> "5"
            else -> ""
        }
    }

    println(paw)
//    模拟解密
    val str = paw.replace(Regex("[12345]")) {
        when (it.value) {
            "1" -> "Q"
            "2" -> "W"
            "3" -> "E"
            "4" -> "R"
            "5" -> "T"
            else -> ""
        }
    }
    println(str)


}